<!DOCTYPE html>
<html class="loginHtml">
<head>
    <meta charset="utf-8">
    <title>帮客卖家后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="<?php echo ADMIN?>images/favicon.ico">
    <link rel="stylesheet" href="<?php echo _PUBLIC ?>layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="<?php echo ADMIN ?>css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space20" id="form_reg">
    <div class="">
        <div class="layui-row layui-col-space10">
            <div class="layui-form-item input-item magt3">
                <label for="userName" class="layui-form-label" style="width: 90px;">手机号</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="text" placeholder="请输入手机号" name="phone" autocomplete="off" id="reg_phone" class="layui-input name" lay-verify="required">
                    <input type="hidden" placeholder="" name="id" autocomplete="off" id="id" class="layui-input name" lay-verify="required">
                </div>
            </div>

            <div class="layui-form-item input-item magt3">
                <label for="userName" class="layui-form-label" style="width: 90px;">请输入手机验证码</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="text" placeholder="请输入手机验证码" autocomplete="off" name="yzm" id="yzm" style="width:60%;display:inline" class="layui-input name" lay-verify="required">
                    <a id="send_sms" class="layui-btn layui-btn-primary" style="width:39%;float:right">发送验证码</a>
                </div>
            </div>

            <div class="layui-form-item input-item magt3">
                <label for="password" class="layui-form-label" style="width: 90px;">支付宝姓名</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="text" placeholder="请输入支付宝姓名" autocomplete="off" name="account" id="account" class="layui-input name" lay-verify="required">
                </div>
            </div>

            <div class="layui-form-item input-item">
                <label for="password" class="layui-form-label" style="width: 90px;">支付宝账号</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="text" placeholder="请输入支付宝账号" autocomplete="off" name="user_name" id="user_name" class="layui-input name" lay-verify="required">
                </div>
            </div>

            <div class="layui-form-item input-item magt3">
                <label for="password" class="layui-form-label" style="width: 90px;">交易密码</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="password" placeholder="请输入交易密码" name="password" autocomplete="off" id="password" class="layui-input" lay-verify="required">
                </div>
            </div>

            <div class="layui-form-item input-item">
                <label for="password" class="layui-form-label" style="width: 90px;">请再次输入交易密码</label>
                <div class="layui-input-block" style="margin-left: 130px; width: 500px;">
                    <input type="password" placeholder="请再次输入交易密码" autocomplete="off" name="password_reapeat" id="password_reapeat" class="layui-input" lay-verify="required">
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-block" id="reg" lay-filter="reg" lay-submit>修改</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="<?php echo _PUBLIC ?>layui/layui.js"></script>
<script type="text/javascript" src="<?php echo ADMIN ?>js/cache.js"></script>
</body>
<script type="text/javascript">
    layui.use(['form','layer','jquery'],function() {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer
        $ = layui.jquery;

        //表单输入效果
        $(".childrenBody .input-item").click(function (e) {
            e.stopPropagation();
            $(this).addClass("layui-input-focus").find(".layui-input").focus();
        })
        $(".childrenBody .layui-form-item .layui-input").focus(function () {
            $(this).parent().addClass("layui-input-focus");
        })
        $(".childrenBody .layui-form-item .layui-input").blur(function () {
            $(this).parent().removeClass("layui-input-focus");
            if ($(this).val() != '') {
                $(this).parent().addClass("layui-input-active");
            } else {
                $(this).parent().removeClass("layui-input-active");
            }
        })

        $('#send_sms').click(function(){
            var phone=$("#reg_phone").val();
            console.log(phone);
            if(!phone){
                layer.msg('手机号不能为空');
                return;
            }
            $.ajax({		//验证验证码
                type:'post',
                data:{phone:phone},
                dataType:'json',
                url:"<?php echo site_url('app/me/user/sendSms')?>",
                success:function(res){
                    if(res.code==200){
                        layer.msg('验证码发送成功');
                    }else{
                        layer.msg('验证码发送失败');
                    }

                },
                fail:function(){
                    layer.msg('验证码发送失败');
                }
            })
        })
        //注册
        form.on('submit(reg)', function(data){
            var data=data.field;
            if(!data.yzm){
                layer.msg('验证码不能为空');
            }else if(data.password!=data.password_reapeat){
                layer.msg('两次密码输入不一致');
            }else if(data.password.length !== 6){
                layer.msg('密码必须位6位数字');
            }else{
                $.ajax({		//验证验证码
                    type:'post',
                    data:{yzm:data.yzm},
                    dataType:'json',
                    url:"<?php echo site_url('app/me/user/checkSms')?>",
                    success:function(res){
                        if(res.code==200){
                            $.ajax({
                                type:'post',
                                data:data,
                                dataType:'json',
                                url:"<?php echo site_url('seller/finance/update')?>",
                                success:function(res){
                                    if(res.code==200){
                                        layer.msg('修改成功，等待审核');
                                        location.href="<?php echo site_url('seller/finance/index')?>";
                                    }else{
                                        layer.msg(res.msg);
                                    }
                                },
                                fail:function(){

                                }
                            })
                        }else{
                            layer.msg('手机验证码输入错误');
                        }

                    },
                    fail:function(){

                    }
                })
            }
        });
    })
</script>
</html>